package com.kgc.novel.controller;

import com.kgc.novel.common.Res;
import com.kgc.novel.domain.entity.BookAdvice;
import com.kgc.novel.domain.entity.BookShelf;
import com.kgc.novel.domain.param.BookAdviceParam;
import com.kgc.novel.domain.param.BookShelfParam;
import com.kgc.novel.service.user.BookAdviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Wang乐俊.
 * @date 2023/5/9 0009 19:42
 * @Version: 1.0
 */
@RestController
@RequestMapping("/advice")
@Slf4j
@Api("通知公告管理")
@CrossOrigin
public class BookAdviceController {
    @Resource
    private BookAdviceService bookAdviceService;

    @PostMapping("/list")
    @ApiOperation("查询全部信息")
    public Res selectList(@RequestBody(required = false) BookAdviceParam bookAdviceParam) {
        return bookAdviceService.selectAdviceAll(bookAdviceParam);
    }

    @GetMapping("/select/{id}")
    @ApiOperation("查询单个信息")
    public Res selectShelf(@PathVariable("id") String id) {
        return bookAdviceService.getSingleAdvice(id);
    }

    @PostMapping("/add")
    @ApiOperation("新增单个信息")
    public Res addShelf(@RequestBody(required = true) BookAdvice bookAdvice) {
        return bookAdviceService.addAdvice(bookAdvice);
    }

    @PutMapping("/update")
    @ApiOperation("修改单个信息")
    public Res updateShelf(@RequestBody(required = true) BookAdvice bookAdvice) {
        return bookAdviceService.updateAdvice(bookAdvice);
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除单个信息")
    public Res deleteShelf(@PathVariable("id") String id) {
        return bookAdviceService.deleteAdvice(id);
    }

    @GetMapping("/deleteAll/{ids}")
    @ApiOperation("批量删除信息")
    public Res deleteAllShelf(@PathVariable("ids") List<String> ids) {
        return bookAdviceService.deleteAllAdvice(ids);
    }
}
